package com.example.sentinel.service;


import ch.qos.logback.core.Layout;
import com.alibaba.csp.sentinel.annotation.SentinelResource;
import org.openjdk.jol.info.ClassLayout;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.concurrent.LinkedBlockingDeque;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

@Service
public class TestService {

    @SentinelResource(value = "test", blockHandler = "fallback")
    public String test(){
        ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(2,5,3000, TimeUnit.MILLISECONDS,new LinkedBlockingDeque<>());
        return "get success";
    }

    public String fallback(){
        return "fallback";
    }

    public static class T{
        int m = 8;
    }
    public static void main(String[] args) {
//        Object o = new Object();
        T o = new T();
        String s = ClassLayout.parseInstance(o).toPrintable();
        System.out.println(s);
        synchronized (o){
            System.out.println(ClassLayout.parseInstance(o).toPrintable());
        }

    }

}
